package com.gg.haoqi.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.gg.haoqi.R;
import com.gg.haoqi.bean.Category;
import com.gg.haoqi.utils.ImageLoaderUtils;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by GG on 2015/11/9.
 */
public class DrawerListAdapter extends AppBaseAdapter<Category> {

    public DrawerListAdapter(List<Category> list, Context context) {
        super(list, context);
    }

    @Override
    public ViewHolder getViewHolder(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = AppBaseAdapter.ViewHolder.get(context, convertView, parent, R.layout.item_drawer_list);

        ImageView iv = (ImageView) holder.findViewById(R.id.drawer_item_icon);
        TextView tv = (TextView) holder.findViewById(R.id.drawer_item_name);

        Category category = list.get(position);
        ImageLoader.getInstance().displayImage(category.getImage(), iv, ImageLoaderUtils.getDisplayImageLoader());
        tv.setText(category.getTitle());

        return holder;
    }
}
